package leetcode.code;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution268 implements IDebug {

	public int missingNumber(int[] nums) {
		int n = nums.length; // n个数
		int ans = (1 + n) * n >> 1; // n个数的和
		for (int num : nums) {
			ans -= num;// 减去每一个数
		}
		return ans;// 得到答案
	}

	@Override
	public void debug1() {
		String str = "[3,0,1]";
		int[] nums = HelpDebug.str2array3(str);
		int e = 2;
		int r = this.missingNumber(nums);
		HelpDebug.compare(e, r);
	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution268 so = new Solution268();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
